package org.openintents.droidcon.cloud.mvc;

import org.openintents.droidcon.cloud.model.Schedule;

public class ScheduleForm {

	private Schedule editSchedule = null;

	public ScheduleForm(Schedule editSchedule) {
		if (editSchedule != null) {
			this.editSchedule = editSchedule;
		}
	}

	public String display() {
		String output = "<form action=\"/droidconcloud/schedule\" method=\"post\">"
				+ "<fieldset><legend>Schedule</legend>"
				+ "<label for=\"name\">Schedule name:</label> "
				+ "<input type=\"text\" name=\"name\" id=\"name\" value=\""
				+ (editSchedule != null ? editSchedule.getName() : "")
				+ "\" />"
				+ "<label for=\"location\">Schedule location:</label> "
				+ "<input type=\"text\" name=\"location\" id=\"location\" value=\""
				+ (editSchedule != null ? editSchedule.getLocation() : "")
				+ "\" />"
				+ "<label for=\"date\">Schedule date:</label> "
				+ "<input type=\"text\" name=\"date\" id=\"date\" value=\""
				+ (editSchedule != null ? editSchedule.getDateString() : "")
				+ "\" />"
				+ (editSchedule != null ? "<input type=\"hidden\" name=\"id\" value=\""
						+ editSchedule.getId() + "\" />"
						: "")
				+ (editSchedule == null ? "<input type=\"hidden\" name=\"action\" value=\"add\" />"
						: "")
				+ (editSchedule != null ? "<input type=\"hidden\" name=\"action\" value=\"edit\" />"
						: "") + "<input type=\"submit\" value=\""
				+ (editSchedule != null ? "edit" : "add") + " schedule\" /> "
				+ "<input type=\"submit\" name=\"action\" value=\"reset\" />"
				+ "</fieldset>" + "</form>";		
		return output;
	}

}
